<template>
    <div class="center h-100">
        <elewarp>
            <span slot="search-header">数据筛选</span>
            <el-form slot="search" :inline="true" :model="search" class="demo-form-inline" ref="searchform">
                <el-form-item label="总结名称" prop="bW_Name">
                    <el-input v-model="search.bW_Name" placeholder="总结名称"></el-input>
                </el-form-item>
                <el-form-item label="日期范围" prop="date">
                    <el-date-picker
                    v-model="search.date"
                    type="daterange"
                    value-format="yyyy-MM-dd"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期">
                  </el-date-picker>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">查询</el-button>
                    <el-button @click="onReset">重置</el-button>
                </el-form-item>
            </el-form>
            <div slot="table-header">
                <span>总结列表</span>
                <el-button @click="addSummarynfo" style="float: right; margin-right:10px;" type="primary">添加</el-button>
            </div>
            <div slot="table">
                <ul class="card-list">
                    <li class="card-item" style="margin-bottom:20px;"  v-for="(item, index) in lists" :key="index">
                        <el-card shadow="never">
                            <div class="clearfix" style="padding: 14px;">
                                <div class="fl pointer" @click="lookinfo(item)">
                                    <h2>主题：{{item.W_Name}}</h2>
                                    <ul style="font-size:12px;">
                                        <li>
                                            <i class="el-icon-timer"></i>
                                            <span>发布时间：</span>
                                            <span>{{item.AddTime}}</span>
                                        </li>
                                    </ul>
                                </div>
                                
                                <div class="fr" style="margin-left:20px;">
                                    <div style="margin-bottom:5px;">
                                        <el-button title="删除" @click="handleClickdelete(item)"  size="mini" class="button"><i class="el-icon-delete"></i>删除</el-button>
                                    </div>
                                    <div>
                                        <el-button title="编辑" @click="handleClickedit(item)" size="mini" class="button"><i class="el-icon-edit"></i>编辑</el-button>
                                    </div>
                                </div>
                                <div class="fr t-c">
                                    <!-- <img width="50px" height="50px" src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png" class="image"> -->
                                    <p style="margin-top:36px;">{{item.AddUser}}</p>
                                </div>
                                
                            </div>
                        </el-card>
                    </li>
                </ul>
                <div class="bottom-pages clearfix">
                    <div class="fr">
                        <el-pagination
                        background
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="currentPage"
                        :page-sizes="[9, 15, 21, 30]"
                        :page-size="pageSize"
                        :pager-count="5"
                        layout="total, sizes, prev, pager, next"
                        :total="count">
                        </el-pagination>
                    </div>
                </div>
            </div>
        </elewarp>
        <!-- <ele-add-study ref="addstudy"></ele-add-study> -->
    </div>
</template>

<script>
import elewarp from '@/components/warp-slot.vue'
// 添加学生
import {getworklist,deletworklist} from '@/api/index.js';

export default {
    name: 'center',
    components: {
        elewarp,
        // eleAddStudy
    },
    data() {
        return {
            search:{
                bW_Name:'',
            },
            count:0,
            lists:[],
            pageSize:10,
            currentPage:1,
            tableSelection:[]
        }
    },
    created() {
        this.getsummarylist()
    },
    methods:{
        onSubmit(){
            this.getsummarylist()
        },
        getsummarylist(){
            let params = {
                ...this.search,
                bPage:(this.currentPage - 1) * this.pageSize + 1,
                bPage1:this.currentPage * this.pageSize,
                bSort:'',
                bSx:''
            }
            getworklist(params).then((res) => {
                if(res) {
                    this.lists = res.tableData;
                    this.count = res.total_rows;
                }
            })
        },
        onReset(){
            this.$refs.searchform.resetFields();
            this.getsummarylist();
        },
        handleSelectionChange(row){
            console.log(row)
            this.tableSelection = row;
        },
        handleSizeChange(val){
            this.pageSize = val;
            this.getsummarylist()
        },
        handleCurrentChange(val){
            this.currentPage = val;
            this.getsummarylist()
        },
        // 编辑
        handleClickedit(row){
            // this.$refs.addstudy.dialogVisible = true;
            this.$router.push({path:'/summaryAdd',query:{id:row.WID}})
        },
        // 查看
        lookinfo(info){
            this.$router.push({path:'/summarydes',query:{id:info.WID}})
        },
        // 删除
        handleClickdelete(row){
            this.$util.openTips.call(this,'是否确定删除？')
            .then((res) => {
                deletworklist({bWID:row.WID}).then((res) => {
                    if(res) {
                        this.$util.tipsMsg('success','删除成功！');
                        this.getsummarylist()
                    }
                })
            }).catch((err) => {
                console.log(err)
            })
        },
        // 添加总结
        addSummarynfo(){
            // this.$refs.addstudy.dialogVisible = true;
            this.$router.push({path:'/summaryAdd'})
        }
    }
}
</script>
<style lang="less" scoped>
.card-list{
    h2{
        margin-bottom: 20px;
    }
}
.image{
    border-radius: 50%;
}
</style>
